<?php
namespace Admin\Controller;

use Think\Controller;

class SystemController extends CommonController
{
    private $user;

    public function __construct()
    {
        parent::__construct();
        $this->user = M("user");
    }


    function password_change()
    {
        $this->display();

    }


    function do_change()
    {
        $id = I("post.id");
        $password = I("post.password");
        if ($_SESSION['user']['password'] != substr(md5(I("post.old_password")), 6, -6)){
            $this->error('原始密码不正确');
    }
        $password = substr(md5(I("post.password")), 6, -6);
        $User = M('user');
        $User->where("id='$id'")->setField('password', $password);

        //修改密码的代码

        $this->success('您已经成功修改密码, 请重新登录', U('Admin/User/logout'));
    }


    function info()
    {
        $this->display();
    }
}
